<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Examples (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Examples (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Examples (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Mode-Iterators.html" rel="up" title="Mode Iterators">
<link href="Substitutions.html" rel="prev" title="Substitutions">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="subsubsection-level-extent" id="Examples">
<div class="nav-panel">
<p>
Previous: <a href="Substitutions.html" accesskey="p" rel="prev">Substitution in Mode Iterators</a>, Up: <a href="Mode-Iterators.html" accesskey="u" rel="up">Mode Iterators</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h4 class="subsubsection" id="Mode-Iterator-Examples"><span>17.23.1.3 Mode Iterator Examples<a class="copiable-link" href="#Mode-Iterator-Examples"> &para;</a></span></h4>

<p>Here is an example from the MIPS port.  It defines the following
modes and attributes (among others):
</p>
<div class="example smallexample">
<pre class="example-preformatted">(define_mode_iterator GPR [SI (DI &quot;TARGET_64BIT&quot;)])
(define_mode_attr d [(SI &quot;&quot;) (DI &quot;d&quot;)])
</pre></div>

<p>and uses the following template to define both <code class="code">subsi3</code>
and <code class="code">subdi3</code>:
</p>
<div class="example smallexample">
<pre class="example-preformatted">(define_insn &quot;sub&lt;mode&gt;3&quot;
  [(set (match_operand:GPR 0 &quot;register_operand&quot; &quot;=d&quot;)
        (minus:GPR (match_operand:GPR 1 &quot;register_operand&quot; &quot;d&quot;)
                   (match_operand:GPR 2 &quot;register_operand&quot; &quot;d&quot;)))]
  &quot;&quot;
  &quot;&lt;d&gt;subu\t%0,%1,%2&quot;
  [(set_attr &quot;type&quot; &quot;arith&quot;)
   (set_attr &quot;mode&quot; &quot;&lt;MODE&gt;&quot;)])
</pre></div>

<p>This is exactly equivalent to:
</p>
<div class="example smallexample">
<pre class="example-preformatted">(define_insn &quot;subsi3&quot;
  [(set (match_operand:SI 0 &quot;register_operand&quot; &quot;=d&quot;)
        (minus:SI (match_operand:SI 1 &quot;register_operand&quot; &quot;d&quot;)
                  (match_operand:SI 2 &quot;register_operand&quot; &quot;d&quot;)))]
  &quot;&quot;
  &quot;subu\t%0,%1,%2&quot;
  [(set_attr &quot;type&quot; &quot;arith&quot;)
   (set_attr &quot;mode&quot; &quot;SI&quot;)])

(define_insn &quot;subdi3&quot;
  [(set (match_operand:DI 0 &quot;register_operand&quot; &quot;=d&quot;)
        (minus:DI (match_operand:DI 1 &quot;register_operand&quot; &quot;d&quot;)
                  (match_operand:DI 2 &quot;register_operand&quot; &quot;d&quot;)))]
  &quot;TARGET_64BIT&quot;
  &quot;dsubu\t%0,%1,%2&quot;
  [(set_attr &quot;type&quot; &quot;arith&quot;)
   (set_attr &quot;mode&quot; &quot;DI&quot;)])
</pre></div>

</div>



</body>
</html>
